﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Commonlib;
using System.Data;
namespace AlbonWeb
{
    public partial class Menu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindRep(0, repMain);
            }
        }

        //绑定子菜单 
        protected void repMain_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            int parentid = int.Parse(((HiddenField)e.Item.FindControl("parentID")).Value);
            Repeater rep = (Repeater)e.Item.FindControl("repMenu");
            bindRep(parentid, rep);
        }

        //根据父ID绑定菜单
        protected void bindRep(int parentid, Repeater rep)
        {
            BLL.UserBLL userbll = new BLL.UserBLL();
            string cmdstr = "select * from Menu where active=1 and ID in ("+userbll.getMenuList(User.Identity.Name)
                +") and parentID="+parentid.ToString()+" order by sequence asc";
            SqlHelper.BindRepeater(rep, SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }
    }
}